package com.wc.alorithm_luogu.P1598;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/23 21:09
 * @description https://www.luogu.com.cn/problem/P1598
 * 垂直柱状图
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int[] letters = new int[128];

        String s;
        int max = 0;

        // 不断的输入
        while (sc.hasNextLine()) {
            s = sc.nextLine();
            for (char chs : s.toCharArray()) {
                letters[chs]++;
            }
        }

        // 计算出最大的数
        for (int i = 'A'; i < 'Z'; i++) {
            max = Math.max(letters[i], max);
        }
        // 打印输出
        for (int i = max; i >= 1; i--) {
            // 大于等于最大值得时候就输入* 否则得输出空格
            if (letters['A'] >= i) {
                System.out.print("*");
            } else {
                System.out.print(" ");
            }
            for (int j = 'B'; j <= 'Z'; j++) {
                if (letters[j] >= i) {
                    System.out.print(" *");
                } else {
                    System.out.print("  ");
                }
            }
            System.out.println();
        }

        // 最终打印
        System.out.print("A");
        for (char i = 'B'; i <= 'Z'; i++) {
            System.out.print(" " + i);
        }
    }
}
